<template>
<div class="codebg"> 
 <div class="qrcode" ref="qrCodeUrl"></div>  
 </div>
</template>

<script>
	
import QRCode from 'qrcodejs2'
import http from '@/utils/request'

    export default {
		props:["vx"],
        methods: {
		creatQrCode() {
			http.get(`/wxPay`).then(
				res=>{
					new QRCode(this.$refs.qrCodeUrl, {
									text: res.data, // 需要转换为二维码的内容
									width: 200,
									height: 200,
									colorDark: '#000000',
									colorLight: '#ffffff',
									correctLevel: QRCode.CorrectLevel.H
			})
			this.isPayed()
				}
			)			
	},
isPayed(){
http.get("/pay/isPayed").then(
res=>{
if(res.data==1){
	this.$router.push('/paySuccess')
}else{
	setTimeout(()=>{
	this.isPayed()
	},2000)
	}
	}
	)
	},
},
mounted() {
    this.creatQrCode();
},
      
}
</script>

<style scoped>
.codebg{
	width: 464px;
	height: 565px;
	background:url("https://spring1024.oss-cn-beijing.aliyuncs.com/2022/02/22/0a4120dc4ca04960826d96e5b7b86aa7wxbk.png");
  
}
.qrcode{
	padding: 272px 132px;
}
</style>